﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Edu.Web.Data.Entity;
using Edu.Web.Data.Service;
using ESoft.Core.Logging;
using Microsoft.AspNetCore.Mvc;

namespace WebAPiDEMO.Controllers
{
    [Route("/api/Values")]
    public class ValuesController : Controller
    {
        private readonly ILogger logger = LogManager.GetLogger(typeof(ValuesController));
        private readonly INoticeService noticeService;

        public ValuesController(INoticeService noticeService)
        {
            this.noticeService = noticeService;
        }

        // GET api/values
        [HttpGet]
        public NoticeEntity Get()
        {
           var cnt = this.noticeService.Count(x=>x.CourceId.HasValue);
            logger.Info(cnt.ToString());
            return noticeService.Add(new NoticeEntity() { Content = "1", CourceId = 3, CreateTime = DateTime.Now, CreateUserId = 1,NoticeType = 1, Title = "测试" });
        }

        // GET api/values/5
        [HttpGet("{id}")]
        public string Get(int id)
        {
            return "value";
        }

        // POST api/values
        [HttpPost]
        public void Post([FromBody]string value)
        {
        }

        // PUT api/values/5
        [HttpPut("{id}")]
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/values/5
        [HttpDelete("{id}")]
        public void Delete(int id)
        {
        }
    }
}
